package com.wl.ms.seckill.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wl.ms.seckill.dao.StockDao;
import com.wl.ms.seckill.entity.Stock;
import com.wl.ms.seckill.service.StockService;
import org.springframework.stereotype.Service;

/**
 * @author wanlei
 * @since 2021/9/24
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockDao, Stock> implements StockService {

    @Override
    public Stock getStockById(int sid) {
        return this.getOne(Wrappers.<Stock>lambdaQuery().eq(Stock::getId, sid));
    }

    @Override
    public int updateStockByOptimistic(Stock stock) {
        return baseMapper.updateByOptimistic(stock);
    }
}
